/****************************************************************************

 Copyright (C) 2009 Jean Pierre Charalambos. All rights reserved.

 Jean Pierre Charalambos (http://dis.unal.edu.co/profesores/pierre/) is an
 Affiliate Associate Professor of the Faculty of Engineering at National
 University of Colombia (http://www.unal.edu.co/).

 This file is part of maku version 0.1.

 http://code.google.com/p/maku/
 email: jpcharalambosh@unal.edu.co

 This file may be used under the terms of the GNU General Public License 
 versions 2.0 or 3.0 as published by the Free Software Foundation and
 appearing in the COPYING file included in the packaging of this file.

 This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

*****************************************************************************/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

#include "ui_mainwindow.h"
#include "viewer.h"

class AuxViewer;
class ViewerDock;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QString = "", QWidget *parent = 0);
    ~MainWindow();

protected:
    virtual void keyPressEvent(QKeyEvent *);
    void closeEvent(QCloseEvent *event);

private slots:
    //auto-connected slots like void on_openAction_triggered(); seems to be broken, i.e., they seems to be called twice:
    bool open();
    bool openModel() {
      QString fileName = QFileDialog::getOpenFileName(this, "Choose a model to open", "", "Models (*.obj *off *.om *.ply *.stl *.stla)");
      return openModel(fileName);
    }
    bool openModel(QString);
    bool save();
    bool saveAs();
    bool closeModel();
    void exitApp() {close();}
    void drawCameraAux(bool);
    void refresh();
    void about();
    void documentWasModified();

private:
    Ui::MainWindow ui;
    void createWidgets(bool = true);
    void importActions();

    void readSettings();
    void writeSettings();
    bool maybeSave();
    bool saveFile(const QString &fileName);
    void setCurrentFile(const QString &fileName = "");
    QString strippedName(const QString &fullFileName);

    QString currentFile;
    bool isUntitled;

    Scene *scene;
    Viewer  *viewer;
    AuxViewer *side, *top, *front;
    ViewerDock *sideDockWidget, *topDockWidget, *frontDockWidget;
    #ifdef WITH_GLEW
     QComboBox *shaderComboBox;
     void initGLEW();
    #endif
};

#endif
